package com.fd;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * 数据库连接
 *
 * @author YangXiaoLong
 * @since 1.0.0
 */
public class DatabaseConnection {

    private static Connection connection;

    public static void initConnection(SlowLogProperties slowLogProperties) {
        try {
            //读取配置文件
            connection = DriverManager.getConnection(slowLogProperties.getUrl(), slowLogProperties.getUsername(), slowLogProperties.getPassword());
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }

    /**
     * 获取数据库连接
     *
     * @return {@link Connection}
     * @author YangXiaoLong
     * @since 1.0.0
     */
    public static Connection getConnection() {
        return connection;
    }
}
